package Auxiliar;

/**
 *
 * @author A
 */
public class Fila {
    Item head;
    Item tail;

    public void addItem( Object Obj ){
        Item New = new Item(Obj);

        if(head == null){
            head = New;
            tail = New;
        }
        else{
            tail.setNext( New );
            tail = New;
        }
    }
    
    public Object getItem(){
        
        if(head == null)    /*Fila Vazia*/
            return null;
        
        Item First = head;
        head = head.getNext();
        if(head == null){
            tail = null;
        }
        return First.getObject();
    }
    
    public Fila() {
        head = null;
        tail = null;
    }
    
    public boolean isEmpty() {
        if(head == tail && head == null)
            return true;
        else
            return false;
    }

}

class Item {
    protected Item next;
    private Object Obj;

    public Item(Object Obj){
        this.Obj = Obj;
        this.next = null;
    }

    public Item getNext(){
        return next;
    }

    public void setNext(Item next){
        this.next = next;
    }
    
    public Object getObject(){
        return Obj;
    }
}